<%--
  Created by IntelliJ IDEA.
  User: 乐乐
  Date: 2021/7/10
  Time: 16:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <%String path =request.getContextPath();%>
    <script type="text/javascript" src="<%=path%>/js/jquery-2.1.1.min.js"></script>
    <script type="text/javascript">
        function getInfo() {
            $.ajax({
                url :"<%=path%>/car/updateById",//请求地址
                type : "pos",//请求方式
                data:$("#updateForm").serialize(),
                dataType : "json",
                async :true,
                success : function(result){
                    if (result){
                        alert("修改成功")
                        location.href="<%=path%>/to/toShow"
                    }
                },
                error : function(result){
                    console.log(result)
                    alert("网网络异常,请刷新");
                }
            })
        }
    </script>
</head>
<body>
<form id="updateForm">
        手机名称:<input type="text" name="pname" value="${tp.pname}">
        手机价格:<input type="text" name="pprice" value="${tp.pprice}">
        手机类型:<select name="ctype">
    <option value="0" <c:if test="${tp.ptype==-1}" >selected</c:if>>请选择</option>
                    <c:forEach items="${t}" var="t">
                        <option value="${t.ttype}" <c:if test="${t.ttype == tp.type}">selected</c:if>>${t.ttype}</option>
                    </c:forEach>
                </select>
        上架时间:<input type="text" name="pdate" value="<fmt:formatDate value="${tp.pdate}" pattern="yyyy-MM-dd"/>">
                <input type="button" value="修改" onclick="getInfo()" >
</form>
</body>
</html>
